package com.slt.concurrency.mashibing2019.juc.c_000_Thread;

/**
 *  NEW,RUNNABLE,BLOCKED,WAITING,
 *  TIMED_WAITING,TERMINATED;
 */
public class T05_Interrupt {

    static class MyThread extends Thread {
        @Override
        public void run() {
            for(int i=0; i<10; i++) {
                try {
                    //当前线程睡眠
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    System.out.println(8888);
                    e.printStackTrace();
                }
                System.out.println(i);
            }
        }
    }

    public static void main(String[] args) {
        Thread t = new MyThread();
        t.start();
        try {
            //打断循环的 第一个sleep
            t.interrupt();
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //timed waiting
        System.out.println(t.getState());

    }
}
